Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to pydantic v2 #16

Merged
merged 18 commits into from
Oct 27, 2023
Merged

Update to pydantic v2 #16

merged 18 commits into from
Oct 27, 2023

Conversation

CasperWA
Copy link
Collaborator

@CasperWA CasperWA commented Sep 7, 2023

Use new way of configuring models and new type of validators.

Closes #12

I put this as a draft for now, to determine whether other parts of the code should be re-written according to new pydantic v2 functionality. Like, e.g., the dynamic model creation using create_model().

Furthermore, since dependencies of this package pin pydantic to v1 still, it is difficult to see an update happening right now.


This PR now does a few things, along with migrating to pydantic v2 (EDIT: Nope, it just migrates):

  • Use ruff instead of pylint and isort (this is also implemented in Use ruff #19, so I advice to merge that one first and fix this afterwards).
    EDIT: This has been done.
  • Update type annotations throughout the code base to be Python 3.10 styling (utilizing from __future__ import annotations, which should be removed once the minimum required Python version is set to 3.10).
    EDIT: This has been reverted - it doesn't work. Since Python 3.9 is the minimum supported version, Python 3.9 style typing has been implemented everywhere. Note, this can also be done dynamically using the pyupgrade package with the --py39-plus option (for example as a pre-commit hook, if so desired).

@CasperWA CasperWA marked this pull request as ready for review September 22, 2023 14:11
@CasperWA CasperWA requested a review from quaat September 22, 2023 14:12
This is achieved through `from __future__ import annotations`, which can
be removed once the minimum supported Python version has been upped to
3.10.
Ruff is already run through the pre-commit CI run
Remove commented out pylint config section
Use typing.Annotated and model_dump()
As of v0.4.0, OTELib support pydantic v2.
@CasperWA CasperWA mentioned this pull request Oct 19, 2023
4 tasks
@CasperWA
Copy link
Collaborator Author

CasperWA commented Oct 20, 2023

@quaat and @Treesarj, I think I'll merge this. It shouldn't change any contents, really, just update usage of pydantic to pydantic v2 styling - and then there's a bit of static typing updates as well.

Since both oteapi-core and otelib now support pydantic v2, there are no dependency issues any longer.

@quaat quaat merged commit 9268eb3 into main Oct 27, 2023
4 checks passed
@CasperWA CasperWA deleted the cwa/update-to-pydantic-v2 branch November 7, 2023 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use pydantic v2
2 participants